package com.qmq.app.controller;

import com.qmq.app.annotation.Login;
import com.qmq.app.entity.UserInfo;
import com.qmq.app.entity.UserPassword;
import com.qmq.app.service.UserService;
import com.qmq.common.utils.R;
import io.swagger.annotations.ApiOperation;
import oracle.jdbc.proxy.annotation.Post;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app")
public class AppUserController {

    @Autowired
    private UserService userService;

    @Login
    @ApiOperation("用户重置密码")
    @PostMapping("/reset/password")
    public R reSetPassword(@RequestBody @Validated UserPassword password){
        userService.reSetPassword(password);
        return R.ok("密码重置成功");
    }

    @Login
    @ApiOperation("重置用户信息")
    @PostMapping("/reset/userInfo")
    public R reSetUserInfo(@RequestBody @Validated UserInfo info) {
        return R.ok().put("data",userService.reSetUserInfo(info));
    }

    @Login
    @ApiOperation("获取用户信息")
    @GetMapping("/get/userInfo/{userId}")
    public R userInfo(@PathVariable("userId") Long userId) {
        return R.ok().put("data", userService.getUserInfo(userId));
    }
}
